package com.ruoyi.contract.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.contract.domain.ContractProjectConnection;
import com.ruoyi.contract.service.IContractProjectConnectionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 合同项目连Controller
 * 
 * @author ruoyi
 * @date 2024-10-18
 */
@RestController
@RequestMapping("/contract/ContractProjectConnection")
public class ContractProjectConnectionController extends BaseController
{
    @Autowired
    private IContractProjectConnectionService contractProjectConnectionService;

    /**
     * 查询合同项目连列表
     */
    @PreAuthorize("@ss.hasPermi('contract:ContractProjectConnection:list')")
    @GetMapping("/list")
    public TableDataInfo list(ContractProjectConnection contractProjectConnection)
    {
        startPage();
        List<ContractProjectConnection> list = contractProjectConnectionService.selectContractProjectConnectionList(contractProjectConnection);
        return getDataTable(list);
    }

    /**
     * 导出合同项目连列表
     */
    @PreAuthorize("@ss.hasPermi('contract:ContractProjectConnection:export')")
    @Log(title = "合同项目连", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ContractProjectConnection contractProjectConnection)
    {
        List<ContractProjectConnection> list = contractProjectConnectionService.selectContractProjectConnectionList(contractProjectConnection);
        ExcelUtil<ContractProjectConnection> util = new ExcelUtil<ContractProjectConnection>(ContractProjectConnection.class);
        util.exportExcel(response, list, "合同项目连数据");
    }

    /**
     * 获取合同项目连详细信息
     */
    @PreAuthorize("@ss.hasPermi('contract:ContractProjectConnection:query')")
    @GetMapping(value = "/{contractProjectConnectionId}")
    public AjaxResult getInfo(@PathVariable("contractProjectConnectionId") Long contractProjectConnectionId)
    {
        return success(contractProjectConnectionService.selectContractProjectConnectionByContractProjectConnectionId(contractProjectConnectionId));
    }

    /**
     * 新增合同项目连
     */
    @PreAuthorize("@ss.hasPermi('contract:ContractProjectConnection:add')")
    @Log(title = "合同项目连", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ContractProjectConnection contractProjectConnection)
    {
        return toAjax(contractProjectConnectionService.insertContractProjectConnection(contractProjectConnection));
    }

    /**
     * 修改合同项目连
     */
    @PreAuthorize("@ss.hasPermi('contract:ContractProjectConnection:edit')")
    @Log(title = "合同项目连", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ContractProjectConnection contractProjectConnection)
    {
        return toAjax(contractProjectConnectionService.updateContractProjectConnection(contractProjectConnection));
    }

    /**
     * 删除合同项目连
     */
    @PreAuthorize("@ss.hasPermi('contract:ContractProjectConnection:remove')")
    @Log(title = "合同项目连", businessType = BusinessType.DELETE)
	@DeleteMapping("/{contractProjectConnectionIds}")
    public AjaxResult remove(@PathVariable Long[] contractProjectConnectionIds)
    {
        return toAjax(contractProjectConnectionService.deleteContractProjectConnectionByContractProjectConnectionIds(contractProjectConnectionIds));
    }
}
